﻿using Liang.Util.Crypt.Dll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Liang.Util.Crypt
{
    /// <summary>
    /// 司机卡加解密类
    /// <para>原运销司机卡加解密类，依赖pbdes.dll</para>
    /// </summary>
    class DriverCardCrypt : ICrypt
    {
        public bool Decry(ref byte[] buf, string strKey)
        {
            return false;
        }

        public string DecStr(string strData, string strKey)
        {
            string ret = string.Empty;

            uint len = (uint)strData.Length + 1;
            StringBuilder sb = new StringBuilder((int)len);

            if (0 < CryptAPI.b64_des(strData, sb, strKey, len, 0))
            {
                ret = sb.ToString();
            }

            return ret;
        }

        public bool Encry(ref byte[] buf, string strKey)
        {
            return false;
        }

        public string EncStr(string strData, string strKey)
        {
            string ret = string.Empty;
            uint len = (uint)strData.Length + 1;
            StringBuilder sb = new StringBuilder();

            if (0 < CryptAPI.b64_des(strData, sb, strKey, len, 1))
            {
                ret = sb.ToString();
            }

            return ret;
        }
    }
}
